$(function() {
    function SetCookie(name, value) {
        var dt = 1;
        var exp = new Date();
        exp.setTime(exp.getTime() + dt * 60 * 60 * 1000);
        document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
    }
    function getCookie(name) {
        var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
        if (arr != null) return unescape(arr[2]);
        return null;
    }
    var topTips = "<div id=\"downapp\"><div  style=\"position:absolute;z-index:999997; width:100%;height:100%; background:rgba(0, 0, 0, 0.3);\"></div><div  style=\"position: fixed;z-index:999998; width:100%;height:85px; padding-left:10px; padding-right:10px; background:#F0F1F3;box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"24\"><img id=\"app-close\" src=\"http://img.zto.cn/images/app-close.png\" /></td><td width=\"64\" height=\"80\"><img src=\"http://img.zto.cn/images/ico.jpg\" width=\"56px\"/></td><td><h2 style=\"font-size:16px; padding:5px; margin:0px; padding-left:0px\">中通快递客户端</h2><img src=\"http://img.zto.cn/images/app-dengji.png\" /><br><font style=\"font-size:12px; color:#818181\">随时随地查单、在线下单！</font></td><td><a id=\"downtt\" href=\"http://cnrdn.com/FbWE\"><img src=\"http://img.zto.cn/images/app-down.png\" /></a></td></tr></table></div></div>";
     
    if (getCookie("mobileT") == null) {
        check();
    } else {
         if(getCookie("mobileT") != "true") {
             check();
         }
    }

    function check() {
        var ua = window.navigator.userAgent.toLowerCase();
        if (ua.toLowerCase().indexOf('miuibrowser') != -1) {
            $("body").prepend(topTips);
            $("#downtt").attr("href", "http://cnrdn.com/FbWE");
            $("#downtt").attr("title", "点击下载安卓版本");
        } else {
            if (ua.indexOf('android') != -1) {
                $("body").prepend(topTips);
                $("#downtt").attr("href", "http://cnrdn.com/FbWE");
                $("#downtt").attr("title", "点击下载安卓版本");
            }
            //else if (ua.indexOf('iphone') != -1) {
            //    $("body").prepend(topTips);
            //    SetCookie("mobileT", "true");
            //    $("#downtt").attr("href", "https://itunes.apple.com/cn/app/zhong-tong-kuai-di/id713517954?mt=8");
            //    $("#downtt").attr("title", "点击下载IOS版本");
            //}
        }
    }
    $("#app-close").click(function() {
        $("#downapp").hide();
        SetCookie("mobileT", "true");
    });
    setTimeout(function() {
        $("#downapp").hide();
        SetCookie("mobileT", "true");
    }, 3000); //3秒后自动关闭提示框
     

})